$(function() {
		/*	click();*/
	$.ajax({
		url:'/queryDept',
		type:'get',
		success:function (res) {
			var htmls="";
			for(var i=0;i<res.length;i++){
				htmls+="<option value="+res[i].deptno+">"+res[i].dname+"</option>";
			}
			$("#deptno").empty()
			$("#deptno").append(htmls);
			seleUserById();
		}
	})


		});
function click() {
	 $("[name=uptButton]").bind("click", updUserById);
}
//根据id查询user
function seleUserById() {
	var thisURL = document.URL;
	var getval = thisURL.split('?')[1];
	var userId = getval.split("=")[1];
	
	$.post("queryById",{id:userId}, function(data, stuct) {
		$("#id").val(data.empno);
		$("#ename").val(data.ename);
		$("#job").val(data.job);
		$("#mgr").val(data.mgr);
		$("#hiredate").val(data.hiredate);
		$("#sal").val(data.sal);
		$("#comm").val(data.comm);
		$("#deptno").val(data.deptno);
	},"json");
}

//根据id修改user
function updUserById(){
	var userForm=$("#updUserFrom").serialize();
	$.post("update",userForm, function(data, stuct) {

		window.location.href="manager/index.jsp";

	});


}